package canThreePartsEqualSum;

public class Solution {
    public boolean canThreePartsEqualSum(int[] arr) {
        // 前缀和 + 暴力
        int n = arr.length;
        int []sum = new int[n+1];
        for (int i = 0; i < n; i++) {
            sum[i+1] = arr[i] + sum[i];
        }
        if(sum[n]%3!=0){
            return false;
        }
        for (int i = 1; i < sum.length; i++) {
            for (int j = i+1; j < n; j++) {
                if(sum[i] == sum[j]-sum[i]&& sum[i] == sum[n]-sum[j]){
                    return true;
                }
            }
        }
        return false;
        // sum[i] = sum[j]-sum[i] = sum[n] - sum[j]
    }
}
